home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Dec 3, 1998
- // Author: Bernard Kwok
- //
- // Procedure Name:
- // performPolySetNormal
- //
- // Description:
- // Perform a normal setting on selected vertex normals
- //
- //
-
- proc setOptionVars (int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists polySetNormalFreeze`)
- optionVar -intValue polySetNormalFreeze 0;
- if ($forceFactorySettings || !`optionVar -exists polySetNormalUnFreeze`)
- optionVar -intValue polySetNormalUnFreeze 0;
- if ($forceFactorySettings || !`optionVar -exists polySetNormalX`)
- optionVar -floatValue polySetNormalX 1.0;
- if ($forceFactorySettings || !`optionVar -exists polySetNormalY`)
- optionVar -floatValue polySetNormalY 0.0;
- if ($forceFactorySettings || !`optionVar -exists polySetNormalZ`)
- optionVar -floatValue polySetNormalZ 0.0;
- if ($forceFactorySettings || !`optionVar -exists polySetNormalFreeze`)
- optionVar -intValue polySetNormalFreeze 1;
- }
-
- global proc performPolySetNormalSetup (string $parent, int $forceFactorySettings)
- {
- setOptionVars($forceFactorySettings);
- setParent $parent;
-
- float $fval;
- int $ival, $ival2;
-
- $ival = `optionVar -query polySetNormalFreeze`;
- checkBoxGrp -e -v1 $ival polySetNormalFreeze;
- if ($ival == 1)
- optionVar -intValue polySetNormalFreeze 0;
-
- $ival2 = `optionVar -query polySetNormalUnFreeze`;
- checkBoxGrp -e -v2 $ival2 polySetNormalFreeze;
-
- $fval = `optionVar -query polySetNormalX`;
- floatSliderGrp -edit -value $fval polySetNormalX;
-
- $fval = `optionVar -query polySetNormalY`;
- floatSliderGrp -edit -value $fval polySetNormalY;
-
- $fval = `optionVar -query polySetNormalZ`;
- floatSliderGrp -edit -value $fval polySetNormalZ;
-
- toggleXYZInput 1;
- }
-
- global proc performPolySetNormalCallback (string $parent, int $doIt)
- {
- setParent $parent;
-
- optionVar -intValue polySetNormalFreeze
- `checkBoxGrp -q -v1 polySetNormalFreeze`;
- optionVar -intValue polySetNormalUnFreeze
- `checkBoxGrp -q -v2 polySetNormalFreeze`;
- optionVar -floatValue polySetNormalX
- `floatSliderGrp -query -value polySetNormalX`;
- optionVar -floatValue polySetNormalY
- `floatSliderGrp -query -value polySetNormalY`;
- optionVar -floatValue polySetNormalZ
- `floatSliderGrp -query -value polySetNormalZ`;
-
- toggleXYZInput 1;
-
- if ($doIt) {
- performPolySetNormal 0;
- addToRecentCommandQueue "performPolySetNormal 0" "PolySetNormal";
- }
- }
-
- global proc normalizeNormalValues()
- {
- float $x = `floatSliderGrp -query -value polySetNormalX`;
- float $y = `floatSliderGrp -query -value polySetNormalY`;
- float $z = `floatSliderGrp -query -value polySetNormalZ`;
-
- float $lenSq = $x*$x + $y*$y + $z*$z;
- $lenSq = `sqrt $lenSq`;
- if ($lenSq == 0.0)
- $lenSq = 1.0;
-
- $x = $x / $lenSq;
- $y = $y / $lenSq;
- $z = $z / $lenSq;
-
- floatSliderGrp -edit -value $x polySetNormalX;
- floatSliderGrp -edit -value $y polySetNormalY;
- floatSliderGrp -edit -value $z polySetNormalZ;
- }
-
- global proc toggleXYZInput(int $whichChanged)
- {
- int $freeze = `checkBoxGrp -q -v1 polySetNormalFreeze`;
- int $unfreeze = `checkBoxGrp -q -v2 polySetNormalFreeze`;
-
- // Toggle one turns off the other
- if ($whichChanged == 1 && $freeze == 1)
- checkBoxGrp -e -v2 0 polySetNormalFreeze;
- if ($whichChanged == 2 && $unfreeze == 1)
- checkBoxGrp -e -v1 0 polySetNormalFreeze;
-
- if ($freeze == 1 || $unfreeze == 1)
- {
- disable polySetNormalX;
- disable polySetNormalY;
- disable polySetNormalZ;
- }
- else
- {
- disable -v false polySetNormalX;
- disable -v false polySetNormalY;
- disable -v false polySetNormalZ;
- }
- }
-
- proc polySetNormalOptions()
- {
- string $commandName = "performPolySetNormal";
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- string $layout = getOptionBox();
- setParent $layout;
- setUITemplate -pushTemplate DefaultTemplate;
- waitCursor -state 1;
- tabLayout -scr true -tv false;
-
- string $parent = `columnLayout -adjustableColumn 1`;
-
- // Freeze. If this is on disable the rest
- checkBoxGrp -ncb 2
- -l1 "Lock Normals"
- -l2 "Unlock Normals"
- -cc1 "toggleXYZInput 1"
- -cc2 "toggleXYZInput 2"
- polySetNormalFreeze;
-
- // X
- floatSliderGrp -label "X Value"
- -minValue -1. -maxValue 1.
- -fieldMinValue -1. -fieldMaxValue 1.0
- polySetNormalX;
- // Y
- floatSliderGrp -label "Y Value"
- -minValue -1. -maxValue 1.
- -fieldMinValue -1. -fieldMaxValue 1.0
- polySetNormalY;
- // Z
- floatSliderGrp -label "Z Value"
- -minValue -1. -maxValue 1.
- -fieldMinValue -1. -fieldMaxValue 1.0
- polySetNormalZ;
-
- rowLayout -nc 2 -columnAlign 2 "center" alignButtonLayout;
- text -l "";
- button -label "Normalize Normal"
- -align "center"
- -command "normalizeNormalValues";
- setParent ..;
-
- // Force proper setup
- normalizeNormalValues;
- toggleXYZInput 1;
-
- waitCursor -state 0;
- setUITemplate -popTemplate;
-
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit -label "Set Normal"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- setOptionBoxTitle("Polygon Set Vertex Normal Options");
-
- setOptionBoxHelpTag( "SetVertexNormal" );
-
- eval (($setup + " " + $parent + " " + 0));
- showOptionBox();
- }
-
- global proc string performPolySetNormal (int $option)
- {
- string $cmd="";
- string $sel[];
- switch ($option) {
-
- case 1: polySetNormalOptions;
- // Just the option box
- break;
-
- default:
- setOptionVars(false);
-
- int $freeze = `optionVar -query polySetNormalFreeze`;
- int $unfreeze = `optionVar -query polySetNormalUnFreeze`;
- if ($freeze)
- {
- $cmd = "polyNormalPerVertex -fn true";
- }
- // This needs to be changed later to call the
- // proper thing.
- else if ($unfreeze)
- {
- $cmd = "polyNormalPerVertex -ufn true";
- }
- else
- {
- float $x = `optionVar -query polySetNormalX`;
- float $y = `optionVar -query polySetNormalY`;
- float $z = `optionVar -query polySetNormalZ`;
-
- $cmd = ("polyNormalPerVertex -xyz "
- + $x + " "
- + $y + " "
- + $z);
- }
-
- if ($option == 0)
- evalEcho $cmd;
- break;
- }
- return $cmd;
- }
-
-
-
-
-
-